//正则
let form = layui.form
form.verify({
    pwd: [/^\S{6,12}$/, '密码为6-12位,不能有空格'],
    same1: function (val) {
        if( $('.same').val() === val) return "新密码和旧密码不能一致"
    },
    same: function (val) {
        if($('.yz').val() !== val) return "密码不一致"
    }
})
$('form').on('submit', function (e) {
    e.preventDefault()
    $.ajax({
        type: 'POST',
        url: '/my/user/updatepwd',
        data: $(this).serialize(),
        success: function (res) {
            // console.log(res)
            if (res.status === 0) {
                layer.msg(res.message, {
                    time : 2000
                }, function () {
                    localStorage.removeItem('token')
                    window.parent.location.href = '../login.html'
                })
               
                // $('form')[0].reset()
            } else {
                layer.msg(res.message)
            }
            
        }
    })
})
